package com.ruoyi.kis.mapper;

import com.ruoyi.common.annotation.DataSource;
import com.ruoyi.common.enums.DataSourceType;
import com.ruoyi.kis.domain.*;
import org.apache.ibatis.annotations.MapKey;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.Date;
import java.util.List;
import java.util.Map;

@Mapper
public interface IkisMapper {
//    List<IcItems> queryItems(Date currentTime);
//
    @DataSource(DataSourceType.MASTER)
    Date queryCurrentTime(String tableName);

    @DataSource(DataSourceType.MASTER)
    int updateCurrentTime(Map<String,Object> params);
//
//    List<PoInStock> queryPoinStock(Date poInStockTime);
    @DataSource(DataSourceType.SLAVE)
    List<OutSourceEntryF> queryOutSourceInWareOrder();
    @DataSource(DataSourceType.SLAVE)
    List<OutSourceEntryS> queryOutSourceInWareOrderSById(String fInterID);

    @DataSource(DataSourceType.SLAVE)
    List<ProductStoreF> queryProductStoreF();

    @DataSource(DataSourceType.SLAVE)
    List<ProductStoreS> queryProductStoreSById(String fInterID);

    List<MaterialRequisiteF> queryMaterialRequisiteF();
    List<MaterialRequisiteF> queryMaterialRequisiteF_NX();

    List<MaterialRequisiteS> queryMaterialRequisiteSById(String fInterID);
    List<MaterialRequisiteS> queryMaterialRequisiteSById_NX(String fInterID);

    List<OutboundDelveryOrderF> queryOutboundDelveryOrderF(Date orderTime);

    List<OutboundDelveryOrderS> queryOutboundDelveryOrderSById(String fInterID);

    List<TransferOrderF> queryTransferOrderF();

    List<TransferOrderS> queryTransferOrderSById(String fInterID);

    List<IcItems> queryICITEMS(Date orderTime);

    List<DispatchOrderF> queryDispatchOrderF();

    List<DispatchOrderS> queryDispatchOrderSById(String fInterID);

    Long saveOsInWareOrder(OsInWareOrderF osInWareOrderF);

    int saveOsInWareOrderS(List<OsInWareOrderS> fEntityS);

    String getDeptId(String deptName);

    String getOutSourceEntrySMaxID(String FInterID);
    String getMaxFinterID( String tableName);

    /**
     * 更新最大单据号表的值
     * @param tableName1,tableName2
     */
    void updateICMaxNumFinterID(@Param("tableName1") String tableName1,@Param("tableName2") String tableName2);

    //未启用（updateICMaxNumFinterID方法类似）
    void updateICMaxNumPlusOne(@Param("tableName") String tableName);

    int updateKisICStockBillFlag(@Param("fInterID") String fInterID,@Param("kisFlag") String kisFlag);
    int updateKisPOInstockFlag(@Param("fInterID") String fInterID,@Param("kisFlag") String kisFlag);
    int updateKisSEOutStockFlag(@Param("fInterID") String fInterID,@Param("kisFlag") String kisFlag);


    /**
     * 生产入库单反馈保存
     * @param sclkdFPo
     * @return
     */
    int saveProdStore(SclkdFPo sclkdFPo);

    /**
     * 生产入库单（红）反馈
     * @param sclkdFPo
     * @return
     */
    int updatesclkdF(SclkdFPo sclkdFPo);
    void updatesclkdS(List<SclkdSPo> fEntityS);
    /**
     * 领料单反馈逆向保存
     *
     */
    int saveLldFeedBackReverse(MaterialRequisiteF materialRequisiteF);
    int saveLldFeedBackSReverse(List<MaterialRequisiteS> fEntityS);

    int insertFhtzdFFeedBack(DispatchOrderF dispatchOrderF);

    List<ZjdbdF> queryZjdbdF();

    List<ZjdbdS> queryZjdbdS(String fInterID);


    @Deprecated
    int insertZjdbdFeedBack(ZjdbdF zjdbdF);

    @Deprecated
    int insertZjdbdFeedBackS(List<ZjdbdS> zjbdS);

    List<PdResultF> queryPdF();

    List<PdResultS> queryPdS(String fInterID);

    int insertFhtzdSFeedBack(List<DispatchOrderS> fEntityS);

    int insertPdFeedBack(PdResultF pdResultF);
    int insertPdFeedBackS(List<PdResultS> zjbdS);

    int saveZxckFeedBack(ZxckF zxckF);

    int saveZxckSFeedBack(List<ZxckS> fEntity);

    String queryItemIdByFNumber(String material_code);

    String queryUnitIdByFName(String unit_name);

    int saveZxrkFeedBack(ZxrkF zxrkF);

    int saveZxrkSFeedBack(List<ZxrkS> fEntity);

    List<TltzdF> queryTltzdF();

    List<TltzdS> queryTltzdS(String fInterID);

    List<ThtzdF> queryThtzdF();

    List<ThtzdS> queryThtzdS(String fInterID);

    MaterialRequisiteF querySctldF();

    List<MaterialRequisiteS> querySctldS(String fInterID);

    int saveProdStoreS(List<SclkdSPo> fEntity);

    String queryDepartmentID(String department);
    String queryDepartmentIDByID(String department);
//    String queryDepartmentIDByCode(String department);

    /**
     * 校验入库单是否已经存在
     * @param osInWareOrderF
     * @return
     */
    int checkOsInWareOrderF(OsInWareOrderF osInWareOrderF);

    /**
     * 查询外购入库单据号最大序列号
     * @return
     */
    int queryOsInWareOrderFMaxID(PoDanjuNumber poDanjuNumber);

    /**
     * 获取IC_MaxNum表中是否有已分配的FInterID
     * @param tableName
     * @return
     */
    String getICMaxNum(String tableName);

    int updateIC_MaxNum(@Param("tableName") String icStockBill,@Param("FNumber") String FNumber);

    int updateLldFQty(List<MaterialRequisiteS> fEntityS);
    int updateLldFQtyReverseFeedBack(List<MaterialRequisiteS> fEntityS);

    String getMaxTableFinterID(String tableName);

    int ifExistFinterID(@Param("tableName") String tableName, @Param("FInterID") String FInterID);

//    @Deprecated
    int updateZjdbd(ZjdbdF zjdbdF);
    @Deprecated
    int updateZjdbdS(List<ZjdbdS> fEntity);
    int queryCountICStockBillByFBillNo(ZjdbdF zjdbdF);

    int ifTlOrSlHasBeenUsed(String fBillNo);
    int ifTlOrSlExist(String fBillNo);

    String querySupplierIDByCode(String supplierCode);
    int querySupplierIDIfExists(String supplierID);
    //获取部门ID
    String queryFDeptIDByCode(String fDeptCode);

    String queryWarehouseId(String warehouseCode);

    int queryDeptIDIfExists(String deptID);

//    @MapKey("FEntryID")
    OsInWareOrderS getTlSlId(@Param("FBillNo") String FBillNo, @Param("FItemID") String FItemID,@Param("fBatchNo") String fBatchNo);
    DispatchOrderS getThShId(@Param("FBillNo") String FBillNo, @Param("FItemID") String FItemID,@Param("fBatchNo") String fBatchNo);
    int ifFhOrThExists(String FSourceBillNo);

    int queryOrganizationIDIfExists(String customerID);

    String queryOrganizationIDByCode(String fNumber);

    MaterialRequisiteS queryFinterIDByFBillNoAndMaterialId(@Param("FBillNo") String FBillNo, @Param("FItemID") String FItemID);

    SclkdFPo queryFinterIDByFBillNo(String fBillNo);

    int isIcstockBillCheck(String fBillNo);

    /**
     * 根据zhiKu1FBillerName获取zhiKu1FBillerID
     * @param zhiKu1FBillerName
     * @return zhiKu1FBillerID
     */
    @DataSource(DataSourceType.SLAVE)
    String getFBillerIDByName(String zhiKu1FBillerName);
    @DataSource(DataSourceType.SLAVE)
    String getFFManagerIDByName(String zhiKu1FfManagerName);
    @DataSource(DataSourceType.SLAVE)
    String getFSManagerIDByName(String zhiKu1FsManagerName);


    /**
     * 获取表的最大内码FInterID
     * @param tableName 表名
     * @return
     */
}
